package com.whm.hrmanagement.mapper;

import java.sql.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.whm.hrmanagement.domain.OaStaffAttendance;
import com.whm.hrmanagement.domain.OaStaffQj;
import com.whm.hrmanagement.domain.vo.AttendanceMonthVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 员工考勤Mapper接口
 * 
 * @author whm
 * @date 2024-02-06
 */
public interface OaStaffAttendanceMapper  extends BaseMapper<OaStaffAttendance>
{
    /**
     * 查询员工考勤
     * 
     * @param id 员工考勤主键
     * @return 员工考勤
     */
    public OaStaffAttendance selectOaStaffAttendanceById(Long id);

    @Select("select * from oa_staff_attendance where staff_id = #{id} and date_format(attendance_date,'%Y%m%d') = #{day}")
    OaStaffAttendance findByStaffId(@Param("id") Long id, @Param("day") String day);



    @Select("select count(*) from oa_staff_attendance where  staff_id = #{id} and status = #{status} and date_format(attendance_date,'%Y%m') = #{month} ")
    Integer countTimes(@Param("id") Long id, @Param("status") Integer status, @Param("month") String month);



    @Select("select attendance_date from oa_staff_attendance where  staff_id = #{id} and status=#{status} and date_format(attendance_date,'%Y%m') = #{month} ")
    List<Date> findLeaveDate(@Param("id") Long id, @Param("status") Integer status, @Param("month") String month);

    @Select("select ss.user_id staffId,ss.phonenumber phone,ss.dept_id,ss.nick_name name,ss.phonenumber,sd.dept_name dept_name from sys_user ss inner join sys_dept sd on ss.dept_id = sd.dept_id where ss.del_flag = 0")
    List<AttendanceMonthVO> findAttendanceMonthVO();


    /**
     * 查询员工考勤列表
     * 
     * @param oaStaffAttendance 员工考勤
     * @return 员工考勤集合
     */
    public List<OaStaffAttendance> selectOaStaffAttendanceList(OaStaffAttendance oaStaffAttendance);

    /**
     * 新增员工考勤
     * 
     * @param oaStaffAttendance 员工考勤
     * @return 结果
     */
    public int insertOaStaffAttendance(OaStaffAttendance oaStaffAttendance);

    /**
     * 修改员工考勤
     * 
     * @param oaStaffAttendance 员工考勤
     * @return 结果
     */
    public int updateOaStaffAttendance(OaStaffAttendance oaStaffAttendance);

    /**
     * 删除员工考勤
     * 
     * @param id 员工考勤主键
     * @return 结果
     */
    public int deleteOaStaffAttendanceById(Long id);

    /**
     * 批量删除员工考勤
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteOaStaffAttendanceByIds(Long[] ids);
}
